<?php

namespace Buu\Modules\Domain\Apis;

use App\Http\Controllers\Controller;
use Doraemon\model\DomainConfig\DomainName as mDomainConfig;
use Illuminate\Http\Request;

class Del extends Controller
{
    public function index(Request $request)
    {
        $requestParams = $request->all();
        $domain_name = $requestParams['domain_name'] ? : '';
        if(empty($domain_name)){
            return response()->json([
                'code' => 0,
                'msg' => '参数错误'
            ]);
        }
        $info =  mDomainConfig::selectByWhere(['domain_name' => $domain_name]);
        if(empty($info)){
            return response()->json([
                'code' => 0,
                'msg' => 'domain 不存在'
            ]);
        }
        $result =  mDomainConfig::delete(['domain_name' => $domain_name])->rowCount();
        if($result){
            return response()->json([
                'code' => 1,
                'msg' => '删除成功'
            ]);
        }else{
            return response()->json([
                'code' => 0,
                'msg' => '删除失败'
            ]);
        }
    }

}